from . import baseModel
from datetime import datetime
from sqlalchemy import Column, Integer, String, Boolean, DateTime


# 权限类
class Power(baseModel):
    __tablename__ = "admin_power"
    id = Column(Integer, primary_key=True, comment='权限编号')
    name = Column(String(255), comment='权限名称')
    remark = Column(String(255), comment='说明')
    url = Column(String(255), comment='权限路径')
    open_type = Column(String(10), comment='打开方式')
    parent_id = Column(Integer, comment='父类编号')
    order = Column(Integer, comment='排序')
    create_time = Column(DateTime, default=datetime.now, comment='创建时间')
    update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
    enable = Column(Integer, comment='是否开启')


# 用户权限
class UserPower(baseModel):
    __tablename__ = "admin_user_power"
    id = Column(Integer, primary_key=True, comment='编号')
    user_id = Column(Integer, comment='用户编号')
    power_id = Column(Integer, comment='权限编号')
    create_time = Column(DateTime, default=datetime.now, comment='创建时间')
    update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')